package com.atguigu.gmall.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * 用于渲染订单页面
 */
@Controller
public class OrderController {

    @SuppressWarnings("all")
    @Autowired
    private OrderFeignClient orderFeignClient;

    /**
     * 渲染当前登录用户订单确认页面
     * @param model
     * @return
     */
    @GetMapping("/trade.html")
    public String tradeHtml(Model model){
        //1.远程调用订单微服务,获取订单确认页面相关数据
        Result<Map> result = orderFeignClient.OrderTrade();
        model.addAllAttributes(result.getData());
        //2.渲染页面
        return "/order/trade";
    }

    /**
     * 渲染我的订单页面
     * @return
     */
    @GetMapping("/myOrder.html")
    public String orderHtml(){
        return "/order/myOrder";
    }
}